package com.mingxingyi.applet.controller;


import com.mingxingyi.applet.pojo.dto.UserFriendListDto;
import com.mingxingyi.applet.pojo.dto.UserInfoDto;
import com.mingxingyi.applet.pojo.dto.UserLoginDto;
import com.mingxingyi.applet.pojo.vo.UserFriendListVo;
import com.mingxingyi.applet.pojo.vo.UserInfoVo;
import com.mingxingyi.applet.pojo.vo.UserLoginVo;
import com.mingxingyi.applet.service.UserInfoService;
import com.mingxingyi.base.pojo.RequestDTO;
import com.mingxingyi.base.pojo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("applet")
public class UserInfoController {


    @Autowired
    private UserInfoService userInfoService;


    @PostMapping("loginFirst")
    public ResultVO<UserLoginVo> loginFirst(@RequestParam("file") MultipartFile file,
                                            String username,
                                            String code,
                                            String phoneNumber) throws IOException {
        return userInfoService.loginFirst(file,
                username,
                code,
                phoneNumber);
    }

    @PostMapping("login")
    public ResultVO<UserLoginVo> login(@RequestBody RequestDTO<UserLoginDto> dto) {
        return userInfoService.login(dto);
    }

    @PostMapping("loginOut")
    public ResultVO<UserLoginVo> loginOut(@RequestBody RequestDTO<UserLoginDto> vo) {
        return userInfoService.loginOut(vo);

    }

    @PostMapping("refreshToken")
    public ResultVO<UserInfoVo> refreshToken(@RequestBody RequestDTO<UserInfoDto> vo) {
        return userInfoService.refreshToken(vo);

    }

    @PostMapping("updateUserInfo")
    public ResultVO<UserInfoVo> updateUserInfo(@RequestBody RequestDTO<UserInfoDto> vo) {
        return userInfoService.updateUserInfo(vo);

    }

    @PostMapping("updateRemark")
    public ResultVO<UserFriendListVo> updateRemark(@RequestBody RequestDTO<UserFriendListDto> dtoRequestDTO) {
        return userInfoService.updateRemark(dtoRequestDTO);

    }

    @PostMapping("uploadProfileImage")
    public ResultVO<UserInfoVo> uploadProfileImage(@RequestParam("file") MultipartFile file, Integer userId) throws IOException {
        return userInfoService.uploadProfileImage(file, userId);
    }

    /**
     * 获取分享的uid
     *
     * @param vo
     * @return
     */
    @PostMapping("getShareUid")
    public ResultVO<Object> getShareUid(@RequestBody RequestDTO<UserInfoDto> vo) {
        return userInfoService.getShareUid(vo);

    }

    /**
     * 放开
     *
     * @param vo
     * @return
     */
    @PostMapping("getUserInfoOnFree")
    public ResultVO<UserInfoVo> getUserInfoOnFree(@RequestBody RequestDTO<UserInfoDto> vo) {
        return userInfoService.getUserInfoOnFree(vo);

    }

    @PostMapping("addFriend")
    public ResultVO<UserFriendListVo> addFriend(@RequestBody RequestDTO<UserFriendListDto> vo) {
        return userInfoService.addFriend(vo);
    }

    @PostMapping("deleteFriend")
    public ResultVO<UserFriendListVo> deleteFriend(@RequestBody RequestDTO<UserFriendListDto> vo) {
        return userInfoService.deleteFriend(vo);
    }

    @PostMapping("selectFriendList")
    public ResultVO<UserInfoVo> selectFriendList(@RequestBody RequestDTO<UserInfoVo> vo) {
        return userInfoService.selectFriendList(vo);
    }

    @PostMapping("getPhoneNumber")
    public ResultVO<UserInfoVo> getPhoneNumber(@RequestBody RequestDTO<UserInfoVo> vo) {
        return userInfoService.getPhoneNumber(vo);
    }

    @PostMapping("getPhoneNumberFree")
    public ResultVO<UserInfoVo> getPhoneNumberFree(@RequestBody RequestDTO<UserInfoVo> vo) {
        return userInfoService.getPhoneNumberFree(vo);
    }

}
